﻿using ctolua.sys;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using static ctolua.Data.slk;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace ctolua.Models
{
    /// <summary>
    /// 特效
    /// </summary>
    public class MSfx
    {
        /// <summary>
        /// 特效
        /// </summary>
        public Sfx sfx { get; set; }
        public MSfx(Sfx s) {
            this.sfx = s;
        }
        /// <summary>
        /// 创建特效到单位附加点（跟随旋转使用枚举）
        /// </summary>
        /// <param name="sfx_id"> 特效编号 </param>
        /// <param name="unit"> 单位 </param>
        /// <param name="socket"> 单位挂接点 </param>
        /// <param name="rotate_type"> 跟随旋转方式 2:不跟随旋转 1:跟随模型旋转 0:跟随挂点旋转</param>
        /// <param name="b_follow_scale"> 是否跟随单位缩放 </param>
        /// <param name="scale"> 缩放比例 </param>
        /// <param name="duration"> 持续时间 </param>
        /// <param name="angle"> 角度 </param>
        /// <param name="immediately"> 是否立即删除 </param>
        /// <param name="use_sys_d_destroy_way"> 特效删除的方式是否读表 </param>
        /// <returns>特效</returns>
        public static MSfx create_sfx_on_unit_new(int sfx_id, Unit unit, string socket,    double? duration=1, double? angle=null, double? scale = 1, bool? b_follow_scale = true, int? rotate_type = 2, bool immediately=false, bool use_sys_d_destroy_way=false) {
            if (angle==null)
            {
                angle = unit.get_face_angle().@float();
            }
            return new MSfx(game_api.create_sfx_on_unit_new( sfx_id,  unit,  socket,  rotate_type, b_follow_scale,  scale, duration, angle,  immediately,  use_sys_d_destroy_way)); 
        }
        /// <summary>
        /// 创建特效到点
        /// </summary>
        /// <param name="sfx_id"> 特效编号 </param>
        /// <param name="point"> 点 </param>
        /// <param name="face_angle"> 面向角度 </param>
        /// <param name="scale"> 缩放比例 </param>
        /// <param name="height"> 高度 </param>
        /// <param name="duration"> 持续时间 </param>
        /// <param name="immediately"> 是否立即删除 </param>
        /// <param name="use_sys_d_destroy_way"> 特效删除的方式是否读表 </param>
        public static MSfx create_sfx_on_point(int sfx_id, Point point, double? face_angle = 0, double? scale = 1, double? height=0, double? duration=1, bool? immediately=false, bool? use_sys_d_destroy_way=false)
        {
            return new MSfx(game_api.create_sfx_on_point( sfx_id,  point, face_angle,  scale,  height, duration,  immediately, use_sys_d_destroy_way));
        }
        
        /// <summary>
        /// 删除特效
        /// </summary>
        /// <param name="immediately"> 立即移除表现 </param>
        /// <param name="use_sys_d"> 删除时是否读取系统默认特效 </param>
        /// <returns></returns>
        public void del( bool? immediately=true, bool? use_sys_d=true)
        {
            game_api.delete_sfx(this.sfx, immediately, use_sys_d);
        }
        /// <summary>
        /// 设置特效旋转
        /// </summary>
        /// <param name="rotate_x"> x轴旋转 </param>
        /// <param name="rotate_y"> y轴旋转 </param>
        /// <param name="rotate_z"> z轴旋转 </param>
        /// <returns></returns>
        public void setXYZ(double? rotate_x, double? rotate_y, double? rotate_z)
        {
            game_api.set_sfx_rotate(this.sfx,rotate_x, rotate_y, rotate_z);
        }
        /// <summary>
        /// 设置特效朝向
        /// </summary>
        public void setAngle(double? face_angle)
        {
            game_api.set_sfx_angle(this.sfx, face_angle);
        }
        /// <summary>
        /// 设置特效缩放
        /// </summary>
        /// <param name="scale_x"></param>
        /// <param name="scale_y"></param>
        /// <param name="scale_z"></param>
        public void setScale(double? scale_x, double? scale_y, double? scale_z)
        {
            game_api.set_sfx_scale(this.sfx, scale_x, scale_y, scale_z);
        }
        /// <summary>
        /// 设置特效高度
        /// </summary>
        public void set_sfx_height(double? height)
        {
            game_api.set_sfx_height(this.sfx, height);
        }
        /// <summary>
        /// 设置特效到点
        /// </summary>
        /// <param name="point"> 点 </param>
        /// <param name="fluent_move"> 平滑移动 </param>
        /// <returns></returns>
        public void set_sfx_position(Point point, bool? fluent_move)
        {
            game_api.set_sfx_position(this.sfx, point, fluent_move);
        }
        /// <summary>
        /// 设置特效动画速度
        /// </summary>
        /// <param name="sfx_entity"> 特效 </param>
        /// <param name="speed"> 动画速度 </param>
        /// <returns></returns>
        public void set_sfx_animation_speed(double? speed)
        {
            game_api.set_sfx_animation_speed(this.sfx, speed);
        }
        /// <summary>
        /// 设置特效持续时间
        /// </summary>
        /// <param name="duration"> 持续时间 </param>
        /// <returns></returns>
        public void set_sfx_duration(double? duration)
        {
            game_api.set_sfx_duration(this.sfx, duration);
        }
        /// <summary>
        /// 设置特效颜色
        /// </summary>
        /// <param name="x"> x </param>
        /// <param name="y"> y </param>
        /// <param name="z"> z </param>
        /// <param name="w"> w </param>
        /// <returns></returns>
        public void set_sfx_color(double? x, double? y, double? z, double? w)
        {
            game_api.set_sfx_color(this.sfx, x,y,z,w);
        }


    }
}
